package com.tq68.weixin.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
	
	private static String dateFormat = "yyyy-MM-dd";
	private static String timeFormat = "yyyy-MM-dd HH:mm:ss";
	
	public static String toTimeStr(Date date){
		SimpleDateFormat formatter = new SimpleDateFormat(timeFormat);
		return formatter.format(date);
	}
	
	public static String toDateStr(Date date){
		SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
		return formatter.format(date);
	}
	
	public static Date strToDate(String dateStr) throws ParseException{
		SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
		return formatter.parse(dateStr);
	}
	
	public static Date strToTime(String timeStr) throws ParseException{
		SimpleDateFormat formatter = new SimpleDateFormat(timeFormat);
		return formatter.parse(timeStr);
	}
}
